package com.jcl.recruit.elasticsearch.server;

import com.jcl.core.resp.ApiResponse;
import com.jcl.recruit.elasticsearch.core.entity.ApiChannelAccountParam;
import com.jcl.recruit.elasticsearch.core.entity.ApiResumeCompleteParam;
import com.jcl.recruit.elasticsearch.core.entity.ApiResumeDownloadTaskParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @ClassName ResumeApiServer

 * @Author yyliu
 * @Date 2018/11/23 12:36
 * @Version 1.0
 **/
@Component
public class ResumeApiServer {

    @Autowired
    private ResumeApiProxy resumeApiProxy;
    /**
     * TODO
     *
     * @return void
     * @Date 13:57 2018/11/20
     **/
    public void completeResume(ApiResumeCompleteParam entity) {
        resumeApiProxy.completeResume(entity);
    }

    /**
     * TODO
     *
     * @return void
     * @Date 13:57 2018/11/20
     **/
    public Map<String, Object> getResumeDownList(String corpCode, String source, Integer curPage, Integer pageSize) {

        ApiResumeDownloadTaskParam entity = new ApiResumeDownloadTaskParam();
        entity.setCorpCode(corpCode);
        entity.setSource(source);
        if(!(null != curPage && curPage > 0)){
            curPage = 1;
        }
        entity.setCurPage(curPage);

        if(null != pageSize && pageSize > 0){
            entity.setPageSize(pageSize);
        }

        ApiResponse response = resumeApiProxy.downResumeList(entity);

        return (Map<String, Object>) response.getData();
    }


    /**
     * TODO
     *
     * @return void
     * @Date 13:57 2018/11/20
     **/
    public Map<String, Object> getCorpAccountList(String corpCode, String source, Integer curPage, Integer pageSize) {

        ApiChannelAccountParam entity = new ApiChannelAccountParam();
        entity.setCorpCode(corpCode);
        entity.setSource(source);
        if(!(null != curPage && curPage > 0)){
            curPage = 1;
        }
        entity.setCurPage(curPage);

        if(null != pageSize && pageSize > 0){
            entity.setPageSize(pageSize);
        }

        ApiResponse response = resumeApiProxy.accountList(entity);

        return (Map<String, Object>) response.getData();
    }
}
